package service

import (
	"github.com/kayon/iploc"
	"github.com/mileusna/useragent"
)

var loc *iploc.Locator

func init() {
	loc, _ = iploc.OpenWithoutIndexes("../qqwry.dat")
}

func GetLocFromIP(ip string) *iploc.Detail {
	data := &iploc.Detail{}
	if loc == nil {
		return data
	}

	return loc.Find(ip)
}

func GetUAFromString(s string) useragent.UserAgent {
	ua := useragent.Parse(s)
	return ua
}
